<!DOCTYPE html>
<html>

<head>
	<meta charset="utf-8" />
	<title></title>
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<meta http-equiv=”X-UA-Compatible” content=”IE=edge,chrome=1″/>
	<link rel="stylesheet" type="text/css" href="../../css/defaultcss.css" />
	<link rel="stylesheet" type="text/css" href="../../css/amazeui.min.css" />
	<script type="text/javascript" src="../../js/jquery-1.9.1.min.js"></script>
	<script src='../../js/amazeui.min.js'></script>
	<script src='../../js/flex.js'></script>
	<script src='../../js/index.js'></script>
	<script type="text/javascript" src="../../layer/layer.js"></script>
	<link rel="stylesheet" href="../../css/weui.min.css">
	<link rel="stylesheet" href="../../css/css/stylesheets/index.css">

</head>

<body style="background:#fff;">
	<header>
		<div class="goBack">
			<img src="../../img/base/back.png" alt="返回">
		</div>
		<span class="title"> 律师评价 </span>
	</header>
	<div class="content  evaluate_content" id="evaluate_edit">
		<div class="label">
			请对本次申请预约事宜进行评价
		</div>
		<ul class="evaluate_list">
			<li>
				<img src="../../img/lawer/grey.png" alt="">
				<div class="text">
					不满意
				</div>
			</li>
			<li>
				<img src="../../img/lawer/grey.png" alt="">
			</li>
			<li>
				<img src="../../img/lawer/grey.png" alt="">
			</li>
			<li>
				<img src="../../img/lawer/grey.png" alt="">
			</li>
			<li>
				<img src="../../img/lawer/grey.png" alt="">
				<div class="text active">
					满意
				</div>
			</li>
		</ul>
		<div class="option_btn">
			意见反馈
		</div>
		<div class="option_text">
			<textarea id="evaluation" onpropertychange="checkIntroLength(this);" oninput="checkIntroLength(this);"></textarea>
			<div class="num">
				50字
			</div>
		</div>
		<div class="submitBtn">
			<button class="button" id="submit">
					提交
				</button>
		</div>
		<div class="am-modal am-modal-alert radiusModal" tabindex="-1" id="lawerModal">
			<div class="am-modal-dialog">
				<div class="am-modal-hd">温馨提示</div>
				<div class="am-modal-bd">
					感谢您的评价！
				</div>
				<div class="am-modal-footer">
					<span class="am-modal-btn">确定</span>
				</div>
			</div>
		</div>
	</div>
	<div class="content evaluate_content" id="evaluate_show">
		<div class="label">
		</div>
		<ul class="evaluate_list">
			<li>
				<img src="../../img/lawer/grey.png" alt="">
				<div class="text">
					不满意
				</div>
			</li>
			<li>
				<img src="../../img/lawer/grey.png" alt="">
			</li>
			<li>
				<img src="../../img/lawer/grey.png" alt="">
			</li>
			<li>
				<img src="../../img/lawer/grey.png" alt="">
			</li>
			<li>
				<img src="../../img/lawer/grey.png" alt="">
				<div class="text active">
					满意
				</div>
			</li>
		</ul>
		<div class="option_btn">
			意见反馈
		</div>
		<div class="option_text" id="evaluationDiv">
		</div>
	</div>
</body>

</html>

<script type="text/javascript ">
	var imgUrl1 = '../../img/lawer/grey.png';
	var imgUrl2 = '../../img/lawer/light.png';

	function GetRequest() {
		var url = location.search; //获取url中"?"符后的字串
		var theRequest = new Object();
		if (url.indexOf("?") != -1) {
			var str = url.substr(1);
			strs = str.split("&");
			for (var i = 0; i < strs.length; i++) {
				theRequest[strs[i].split("=")[0]] = decodeURIComponent(strs[i].split("=")[1]);
			}
		}
		return theRequest;
	}
	console.log(GetRequest());
	if (GetRequest()['star_level'] == 0) {
		$("#evaluate_edit").show();
	} else {
		//显示评价内容
		$("#evaluate_show").show();
		for (var i = 0; i < GetRequest()['star_level']; i++) {
			$('#evaluate_show .evaluate_list li:eq(' + i + ')').find('img').attr('src', imgUrl2);
		}
		console.log(GetRequest()['evaluation'])
		$("#evaluationDiv").text(GetRequest()['evaluation'])
	}
	$('.goBack').bind('click', function () {
		window.history.back()
	});
	//提交评价
	var starLevel = 0;
	$("#submit").bind('click', function () {
		if (starLevel == 0) {
			layer.open({
				title: '提示',
				content: "请评价！",
				btn: ['确定'],
			});
			return false;
		}
		HYIP.ajax({
			url: '/lawyerCase/reservationEvaluation.action',
			type: 'post',
			processData: false,
			data: {
				starLevel: starLevel,
				id: GetRequest()['bookingId'],
				evaluation: $('#evaluation').val()
			}
		}, function (data) {
			$("#lawerModal").modal('open');
		});
		return false;
	})

	$("#evaluate_edit li").bind('click', function () {
		if ($(this).hasClass('active')) {
			$(this).nextAll().removeClass('active');
			$(this).nextAll().find('img').attr('src', imgUrl1);
		} else {
			$(this).addClass('active');
			$(this).prevAll().addClass('active');
			$(this).find('img').attr('src', imgUrl2);
			$(this).prevAll().find('img').attr('src', imgUrl2);
		}
		starLevel = $(this).index();
	})

	function checkIntroLength(obj) {
		var max = 50;
		if (obj.value.length > max) {
			obj.value = obj.value.substring(0, max);
		}
		$(".option_text .num").text(50 - obj.value.length + '字');
	}
</script>